 <script type="text/javascript">
 function onSysModuleTree_Click (node) {
 	var node_SysModule = node;
 	$('#dg_SysMouleTree').datagrid({
 		url: '/OA/Admin/SysModule/getCurrentModule?mid=' + node.id
 	})
 }
 </script>
 <div class="easyui-layout" data-options="fit:true,border:false">
 	<div region="north" style="height: 50px; border-width: 0 0 1px 	0; padding: 1px">
 		{$toolbar}
 	</div>
 	<div data-options="region:'west',split:true" style="width:180px;border-left: none">
 		<ul id="tr_sysmodule" class="easyui-tree" data-options="url:'/OA/Admin/SysModule/getModule',onClick:onSysModuleTree_Click">	
 		</ul>
 	</div>
 	<div data-options="region:'center',iconCls:'icon-ok'">
 		<table id="dg_SysMouleTree" class="easyui-datagrid" 
				data-options="
					iconCls: 'icon-edit',
					singleSelect: true,
					method:'get',
					fit:true,
					border:false, 
					onClickRow: onClickRow
				">
			<thead>
				<tr>
					<th data-options="field:'moduleid',width:60">{$moduleid}</th>
					<th data-options="field:'modulename',editor:'text',width:120">{$modulename}</th>
					<th data-options="field:'url',editor:'text',width:180">{$url}</th>
					<th data-options="field:'params',editor:'text',width:120">{$params}</th>
					<th data-options="field:'target',editor:{type:'combobox',options:{data: 
						[
							{'id':'_blank','text':'_blank'},
							{'id':'_top','text':'_top'},
							{'id':'_self','text':'_self'},
							{'id':'_content','text':'_content'}
						],
						valueField:'id',textField:'text'}},width:60">{$target}</th>
					<th data-options="field:'icon',editor:'text',width:80">{$icon}</th>
					<th data-options="field:'sort',editor:'text',width:40">{$sort}</th>
					<th data-options="field:'enus',editor:'text',width:120">{$enus}</th>
					<th data-options="field:'zhcn',editor:'text',width:120">{$zhcn}</th>
					<th data-options="field:'zhtw',editor:'text',width:120">{$zhtw}</th>
				</tr>
			</thead>
		</table>
		<div id="dlg_Add_SysModule" class="easyui-dialog" title="{$addtitle}" style="width:600px;height:300px;padding:2px;"        
			data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true,
				buttons:[{
					text: '{$ok}',
					iconCls: 'icon-ok',
					width:80,
					handler: function(){
						add_SysModule();
					}
				},{
					text: '{$cancel}',
					iconCls: 'icon-cancel',
					width:80,
					handler: function(){
						$('#dlg_Add_SysModule').dialog('close');
					}
				}]">
			<form id="frm_SysModule_Add" method="post" action="/OA/Admin/SysModule/saveModule">
			<table class="tab_grid">
				<tr>
					<td>
						{$moduleid}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_moduleid" type="text" data-options="required:true,validType:'notempty'"/>
					</td>
					<td>
						{$modulename}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_modulename" type="text" data-options="required:true,validType:'notempty'"/>
					</td>
				</tr>
				<tr>
					<td>
						{$moduletype}:
					</td>
					<td>
						<input class="easyui-combobox" name="afld_SysModule_moduletype"    
							data-options="editable:false, required:true, valueField:'id',textField:'text',url:'/OA/Admin/SysModule/getModuleType'">
					</td>
					<td>
						{$url}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_url" type="text"></input>
					</td>
				</tr>
				<tr>
					<td>
						{$target}:
					</td>
					<td>
						<input class="easyui-combobox" name="afld_SysModule_target"    
							data-options="editable:false, required:true, valueField:'id',textField:'text',url:'/OA/Admin/SysModule/getTarget'">
					</td>
					<td>
						{$icon}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_icon" type="text"></input>
					</td>
				</tr>
				<tr>
					<td>
						{$sort}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_sort" type="text"></input>
					</td>
					<td>
						{$enus}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_enus" type="text"></input>
					</td>
				</tr>
				<tr>
					<td>
						{$zhcn}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_zhcn" type="text"></input>
					</td>
					<td>
						{$zhtw}:
					</td>
					<td>
						<input class="easyui-textbox" name="afld_SysModule_zhtw" type="text"></input>
					</td>
				</tr>
			</table>
			</form>
		</div>
	</div>
 </div>
 <script type="text/javascript">
 	//综合查询
 	function query_1001 () {
 		var rows = getQueryRows();
 		alert(JSON.stringify(rows));
 	}
	function save_SysModuleTree () {
		var dg = $('#dg_SysMouleTree');
		if (endEditing(dg)){
			var rows = dg.datagrid('getChanges');
			if(rows.length==0) return;
			$.ajax({
                type: 'POST',
                datatype: 'json',
                url: '/OA/Admin/SysModule/updateModule',
                data: {'updated': JSON.stringify(rows)},
                success: function (data) {
					$.messager.alert(TIP_MSG.TITLE, data.statusmessage,'info');
                }
            });
		}
	}
	function openAddModule () {
		var selectedNode = $('#tr_sysmodule').tree('getSelected');
		if(!selectedNode){
			$.messager.alert(TIP_MSG.TITLE, TIP_MSG.NOSELECT,'warning');
		}else{
			if(selectedNode.attributes.moduletype=='0'){
				$('#dlg_Add_SysModule').dialog('open');
			}else{
				$.messager.alert(TIP_MSG.TITLE, TIP_MSG.ISLEAF,'warning');
			}
		}
	}
	function add_SysModule () {
		$("#frm_SysModule_Add").form("submit",{
			onSubmit: function (param) {
				var selectedNode = $('#tr_sysmodule').tree('getSelected');
				if(selectedNode){
					var mt = selectedNode.attributes.moduletype;
					if(mt == '0'){
						param.afld_SysModule_parentid = selectedNode.id;
						return true;
					}	
				}
                $(this).linkbutton('disable');    //点击就禁用按钮，防止连击
                param.parentid = selectedNode.id;
                if ($(this).form('validate'))
                    return true;
                else {
                    $(this).linkbutton('enable');   //恢复按钮
                    return false;
                }
            },
            success: function (data) {
                    //
            }
		});
	}
	function editButton () {
		var selectedNode = $('#tr_sysmodule').tree('getSelected');
		if(!selectedNode){
			$.messager.alert(TIP_MSG.TITLE, TIP_MSG.NOSELECT,'warning');
		}else{
			if(selectedNode.attributes.moduletype=='0'){
				$.messager.alert(TIP_MSG.TITLE, TIP_MSG.ISLEAF,'warning');
			}else{
				$("<div/>").dialog({
					id: 'dlg_editbutton',
					href: '/OA/Admin/SysModule/editButton',
					title: WIN_TITLE.ADD,
		            height: 500,
		            width: 600,
		            modal: true,
		            buttons:[{
						text: BUTTON_TITLE.OK,
						width:80,
						iconCls: 'icon-ok',
						handler: function(){
							savePageButton(selectedNode.id);
						}
					},{
						text: BUTTON_TITLE.CANCEL,
						width:80,
						iconCls: 'icon-cancel',
						handler: function(){
							$('#dlg_editbutton').dialog('close');
						}
					}],
		            onLoad: function () {
		            	loadButtonlist(selectedNode, 'all');
		            	loadPageButton(selectedNode);
		            },
		            onClose: function () {
		            	$("#dlg_editbutton").dialog('destroy');
		            }
				});
			}
		}
	}
 </script>